Now let's add a local script.
Let's add it right to our screen g ui.
Hit the plus local script and I'm going to call this local script Run Coin award.
There we go.
And I need to get replicated storage so I can catch that event coming over saying, Hey, a player got
got an award, so I need to do a local ask for replicated storage as my variable game, get service,
replicated storage.
Then I'm going to get a remote event and I think I'll name this one a little better.
I'm going to call this award points r e It's going to be in replicated storage.
We'll do a wait for child award points.
R e The only difference is I made that lowercase and this is uppercase.
It's got to match what is in replicated storage.
That's just my convention of how I make my uppercase and lowercase.
But you got to keep it consistent.
All right.
Now what I want to do is I want to get a sound.
I want to get a sound that I can play when we get something.
Let's go to our our game, my zombie game.
Let's go to Toolbox and then click, click audio if it's not already selected.
I was already looking for some audio and I'm going to say something like coin grab or something.
Coin grab.
And there's one.
Perfect.
Wow.
I made it easy.
All right, let's hit the insert.
And it added to whatever was selected over here.
So if it's on the wrong thing, like if it's on the award label, just go ahead and move it.
I want it to be on my my run Coin award script.
I'm going to change the name of my coin.
Grab to just grab.
Here we go.
Grab.
And now let's go to our Run Coin award script.
Open that up and get a reference to that sound.
It's a local sound and it's on the script so we can get the script variable.
I want to do the call and wait for child because screen guys get cloned over.
Sometimes things have to wait a little bit before they're available.
Let's just do a wait for child grab and that's going to get the sound.
Now let's make a function.
We're going to do a lot of stuff in here, but right now we're just going to play that little sound.
It'll be local function on award.
We're also going to get the value coming over of the word like ten points or whatever it is.
Whatever we decide, we have it at ten.
Now let's go.
Sound sad, right?
We're going to get our sound variable colon play.
So every time a word is fired, it's going to play.
How does get fired?
Well, we catch the remote event on this end.
It's fired on the server side.
We're going to do award points, Ari, and it's a dot on client event.
Then we'll do a colon connect on award.
If you get two extra parentheses in here, get rid of them.
You only want the name of the function being called Let's try it out.
Let's hit the play button.
Now we still have our 11 there.
Don't worry, we're going to do something with that.
We're only going to make it up here when we need it.
Now we've got to wait for a coin to pop up in the world.
There's one over there.
I'm going to go run and get it.
I know it's really slow.
Here we go.
There we got our noise.
So this is being triggered on the server side.
We're going through our remote event, and we're hearing it on the client.
Pretty cool.
Let's go ahead and work on our label now.
This label right here is only going to be a temporary thing.
When we grab the coin, it's going to become visible and then it's going to float up out of sight.
So I think what I'm going to do is clone it when I need it.
I'm going to grab this and I'm going to drag this up to replicated storage.
There we go.
And now we don't see it.
That's all right.
We're going to take care of that.
Let's open up our Run Coin award, the script.
There we go.
And we're going to need a few more variables.
We're going to need a template for that little label we got.
We might need a bunch of those little labels if we get coins quickly in a row, So we're going to have
to clone that thing.
I'm going to say local label temp for label template equals replicated storage.
Wait for child.
Now you actually have to spell this right, whatever it is in replicated storage, a ward label, that's
how we spelt it.
And I'm going to get something that I haven't shown you before called the tween service.
Tween service is cool.
You can animate movement of things within your game.
Let's do a tween service equals game.
Get service tween service.
We're going to use that to move the label up out of the screen, out of view of the user.
All right, I'm going to need one more variable, and that's for the screen.
I'll just call it SKU and remember script dot parent, the parent will be there.
We don't have to do a wait for child.
Okay?
Now we have our play.
When we get our award, we know that's firing.
Let's go ahead and clone our label.
I'm going to make a variable label for label.
I'll do label temp, colon, clone, and then label dot parent is going to be the screen.
So we have to attach that new clone somewhere on our screen gooey label text.
What's that going to be?
Well, whatever came over in this vowel, remember, we have it at 11 for testing.
So the vowel we have set to ten on the server side, I'm going to hit that little plus so it shows plus
ten dot dot string concatenate for and then value.
If you're a purist, you can do it just like this.
But if you're a purist, you might want to say to string
value.
But the string concatenate does that for you.
Let's keep it like that though.
It looks fancy.
All right.
Now we have our value, it should say, plus ten on the label.
Now we have to move the label up.
Let's do local.
I'm going to make the variable called tween and we're going to do a TS create.
So tween servers, we're going to create a tween, we're going to tween the label.
And then here we need something called tween info.
We're only going to use the time the tween info gives you stuff like whether you want it to move linearly
or bounce, or you want the bounce at the beginning or the end repeatable, reversible stuff like that.
But I'm going to keep it really simple.
I want to make a simple tween info dot new and just put the time in.
Right?
So this easing style easing direction, that was the stuff I was talking about with the movement, the
fancy movement.
All right.
So we'll do a little bit more of that later.
Let's go ahead and hit these curly brackets.
See that You might not see that on the video.
These are curly brackets, not square brackets.
This is the tween goal.
So wherever it started out to this and you can tween on position or size or color, we're going to tween
on possession, right?
We're going to animate the position up and out of the users view.
Now position in the UI world, the user interface world and roadblocks uses a U dim to was a universal
dimension of two udm two no guess what scale x scale x pixel y scale y pixel.
So on the x, we're going to keep it at 0.5, we're going to keep it in the center zero pixel offset.
But for the Y, the higher you go, the lower the number.
So zero.
I was right at the top of the screen.
Let's make it a -0.5.
So disappears off of the screen.
Zero pixel offset.
I'm going to move this to the next line so you can see it.
All right.
So that is our goal.
We've got to run the tween now, right?
So we created the tween.
Let's do a tween colon play, and then we're going to wait until the tween is completed.
So tween, this is crazy, Dot.
You've got to remember, the difference is between the dots and the colons.
So tween dot completed colon wait means we're going to wait here until the tween completes till we reach
our goal.
And then.
Let's go ahead and destroy our label.
I was going to destroy the tween.
We want to destroy the label.
All right.
That should work.
Let's try it out.
Hit the play.
Your little guy.
I'm going to pause it until the coins pop up.
There you go.
There's a coin.
Ha!
That's pretty good.
Twins move a little fast.
We might want to slow it down.
I think that's fine.
If you want to slow it down, I'm going to show you it's worth it.
If you want to slow it down, you increase your tween time.
Right?
There's a time.
Maybe we'll make it 3 seconds because it is kind of going up off the screen a little bit high.
We could actually reduce this and that will reduce the distance.
It has to move in 2 seconds.
So either one will speed things up.
But I think I'm just going to make this a three and try it again.
I'm going to pause the video till I find a coin.
All right.
I got a coins here.
The minefield.
Let's take a look at our little sign.
Yeah, it's a little slower.
I like that.
All right.